# from pprint import pprint
#
# area_data = [
#     {"id": 1, "name": "中国", "parent_id": 0},
#     {"id": 2, "name": "北京市", "parent_id": 1},
#     {"id": 3, "name": "河北省", "parent_id": 1},
#     {"id": 4, "name": "四川省", "parent_id": 1},
#     {"id": 5, "name": "石家庄市", "parent_id": 3},
#     {"id": 6, "name": "唐山市", "parent_id": 3},
#     {"id": 7, "name": "邢台市", "parent_id": 3},
#     {"id": 8, "name": "成都市", "parent_id": 4},
#     {"id": 9, "name": "简阳市", "parent_id": 4},
#     {"id": 10, "name": "武侯区", "parent_id": 8},
#     {"id": 11, "name": "金牛区", "parent_id": 8},
#     {"id": 12, "name": "高新区", "parent_id": 8},
#     {"id": 13, "name": "非洲", "parent_id": 8},
# ]
#
# data = {i['id']:i for i in area_data}
# l = []
# for k,son in data.items():
#     if son['parent_id'] not in data:
#         l.append(son)
#         continue
#     father = data[son['parent_id']]
#     father['son'] = father.get('son',[]) + [son]
# pprint(l)
# new = []
# def reload(data:list):
#     global new
#     for i in data:
#         if 'son' in i:
#             reload(i.pop('son'))
#         new.append(i)
#
# reload(l)
# pprint(new)

